<%@ page
	import="org.hibernate.*, java.io.*,java.util.*, java.sql.*, org.lionsteins.eddie.server.*, org.lionsteins.eddie.domain.Alert"%>

<%@ page import="java.io.*,java.util.*, javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="org.apache.commons.fileupload.disk.*"%>
<%@ page import="org.apache.commons.fileupload.servlet.*"%>
<%@ page import="org.apache.commons.io.output.*"%>

<%@ page language="java" contentType="text/html; charset=US-ASCII"
	pageEncoding="US-ASCII"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Add Alert Confirmation</title>

<link rel="stylesheet" type="text/css" href="css/mystyles.css" media="screen" />


</head>
<body>

	<%
		String sender = request.getParameter("senderName");
		String latitude = request.getParameter("lat");
		String longitude = request.getParameter("lon");
		String description = request.getParameter("area-description");
		
		
		boolean okay = false;
		try {
			String identifier = UUID.randomUUID().toString()
					.substring(0, 29);
			java.util.Date utilDate = new java.util.Date(
					System.currentTimeMillis());
			java.sql.Date date = new java.sql.Date(utilDate.getTime());

			Alert alert = new Alert();
			alert.setDate(new java.sql.Date(System.currentTimeMillis()));
			alert.setLatString(latitude);
			alert.setLonString(longitude);
			alert.setLocation(description);
			alert.setSender(sender);


			okay = HibernateServiceImpl.addAlert(alert);

		} catch (Exception e) {
			//Handle errors for Class.forName
			e.printStackTrace();
		} finally {
		}//end try
	%>


	<% 
		if (okay) {
			
	%>
	<br>
	</br>
	<br>
	</br>
	
	<table align="center" bgcolor="white" border="1">
	<tr>
	<td>
	Successfully added!!!   
	<br>   
	<br>
	</td>
	</tr>
	<tr>
	<td>
	<a href="alertform.jsp">Add More</a>
	<br>
	</td>
	</tr>
	<tr>
	<td>
	<a href="alertquery.jsp"> View All Alerts</a>
	</td>
	</tr>

	<tr>
	<td>
	<a href="Eddie2.html"> View Map</a>
	</td>
	</tr>

	</table>
	<%  } else {%>

	Failed to add
	<br> Click the back button to go back and re-fix the add.
	<%
		}
		%>

</body>
</html>